import time
import system
import server
import threading

roomList = [200 + i for i in range(10)]
theAC = system.CenturalAC()
theServer = server.Server(port=8000)
theAC.set_para(True, 22., 1, 16, 25,
               {i: i * 0.5 for i in range(4)}, roomList)

theAC.startup()
theRDM = system.RDManager(roomList)
theSch = system.Scheduler(3, 3)
theDB = system.DataBase()

theAC.poweron_ac(room_id=201)
theAC.change_fan_speed(201, 2)
time.sleep(2)
theAC.poweroff_ac(room_id=201, power_off=False)
time.sleep(2)
theAC.change_fan_speed(201, 1)
time.sleep(2)
theAC.change_fan_speed(201, 3)
time.sleep(2)
theAC.poweroff_ac(room_id=201, power_off=False)
time.sleep(4)
theAC.poweroff_ac(room_id=201, power_off=True)
time.sleep(5)
print('stat:', theAC.AC_list[201].get_stat())

rdlist = theRDM.get_mem_rd(201)
for rd in rdlist:
    rd.show()
theRDM.archive_rd(201)
rdlist = theDB.query_details()
for rd in rdlist:
    rd.show()

rfacade = facade.ReceptionFacade(theAC.room_list)
rid = rfacade.checkin()
rid = rfacade.checkin()
print(rfacade.room_stat)

#jsonstr = rfacade.get_RD(rid)
#print(sys.getsizeof(jsonstr))
checkout = rfacade.checkout(201)
theAC.shutdown()  # 关闭系统
